
# 单独处理每一个出现问题的数据,在数据deal的基础上处理完成,覆盖原先的deal,
# 有问题的id



#检查思路
'''
1.读取所有人的数据，查看缺少文件类型，
2.对不同类型的数据的检查，形成一个表格，
1.读取所有人的阶段和la，rpe，和时间开始结束，
2.对比阶段和rpe和la是否对应
3.不对应的数据输出编号，手工查看后进行数据处理
4.处理完的数据再进行一次数据整合
'''
# [1024-1-1,
# 1049-1-1,
# 1050-1-1,
# 1076-1-1,
# 1077-1-1,
# 1083-1-1,
# 1109-1-1,
# 1119-1-1,
# 1125-1-1,
# 1001-1-1,
# 1001-1-2,
# 1002-1-1,
# 1003-1-1,
# 1033-1-1,
# 1034-1-1,
# 1053-1-1,
# 1054-1-1,
# 1059-1-1,
# 1060-1-1,
# 1063-1-1,
# 1066-1-1,
# 1070-1-1,
# 1072-1-1,
# 1087-1-1,
# 1089-1-1,
# 1091-1-1,
# 1101-1-1,
# 1103-1-1,
# 1107-1-1,
# 1111-1-1,
# 1112-1-1,
# 1113-1-1,
# 1115-1-1,
# 1116-1-1,
# 1118-1-1,
# 1121-1-1,
# 1126-1-1,
# 1127-1-1,
# 1129-1-1]
# id=[1001,1003,1024,1033,1034,1049,1050,1053,1054,1059,1060,1063,1066,1070,1072,1076,1077,1083,1087,1089,1091,1101,1103,1107,1109,1111,1112,1113,1115,1116,1118,1119,1121,1125,1126,1127]
import pandas as pd
from data_deal.function import df_get, stage_divide, stage_divide_info
# from huawei室内数据流程 import deal_path
deal_path='D:\\学习&科研\\华为手表项目处理\\dealx'
deal_path=deal_path
def handing_person(person):
    try:
        if globals()['handing_'+person]:
            func=globals()['handing_'+person]
            func()
            print('执行处理',person)
        
    except:
        print('未定义处理函数',person)

def handing_1001():
    print(deal_path)
    person = '1001'
    number = '1001-1-2'
    ecg_df=pd.read_csv(deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv')
    
    number_stage_info=stage_divide_info(number,ecg_df)
    stage_df=stage_divide(number,ecg_df)
    print(stage_df)
    
# handing_1001()



def handing_1003():
    person = '1003'
    number = '1003-1-1'
    ecg_df=pd.read_csv(deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv')
    # print(stage_divide(number,ecg_df))
    # print(ecg_df)


    def modify_value(row):
        x = row['stage']
        idx = row.name
        if x == '-':
            return x
        
        elif  229732<=idx <= 261414:
            return '-'
        elif int(x) >= 3 and idx >= 261414:
            return int(x) + 1
        return str(x)

    ecg_df['stage'] = ecg_df.apply(modify_value, axis=1)
    to_csv_path = deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv'
    ecg_df.to_csv(to_csv_path, index=False)
    # print(stage_divide(number,ecg_df))
    # print(stage_divide_info(number,ecg_df))
    


def handing_1024():
    person = '1024'
    number = '1024-1-1'
    
    ecg_df=pd.read_csv(deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv')
    def modify_value(row):
        x = row['stage']
        psy=row['psychology_RPE']
        phy=row['physiology_RPE']
        idx = row.name
        if x == '-' and (57305<=idx<=57380 or 490779<=idx<=490854 ):
            return (x, '-', '-')
        
        elif  62413<=idx <= 65774:
            return ('-',psy, phy)
        elif  idx >= 65774 and x != '-':
            return  (str(int(x) - 1), psy, phy)
         
        return (str(x),psy,phy)
    
    ecg_df[['stage', 'psychology_RPE', 'physiology_RPE']] = ecg_df.apply(modify_value, axis=1, result_type='expand')
    
    to_csv_path = deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv'
    ecg_df.to_csv(to_csv_path, index=False)
    # print(stage_divide(number,ecg_df))
    # print(stage_divide_info(number,ecg_df))




def handing_1033():
    person = '1033'
    number = '1033-1-1'
    
    ecg_df=pd.read_csv(deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv')
    def modify_value(row):
        x = row['stage']
        psy=row['psychology_RPE']
        phy=row['physiology_RPE']
        idx = row.name

        if    231189<=idx<=243996:
            return ('4',psy, phy)
        elif x>'4':
            return (str(int(x) + 1),psy, phy)
        return (str(x),psy,phy)
    
    ecg_df[['stage', 'psychology_RPE', 'physiology_RPE']] = ecg_df.apply(modify_value, axis=1, result_type='expand')
    
    to_csv_path = deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv'
    ecg_df.to_csv(to_csv_path, index=False)
    # print(stage_divide(number,ecg_df))
    # print(stage_divide_info(number,ecg_df))


def handing_1034():
    person = '1034'
    number = '1034-1-1'
    
    ecg_df=pd.read_csv(deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv')
    def modify_value(row):
        x = row['stage']
        psy=row['psychology_RPE']
        phy=row['physiology_RPE']
        idx = row.name
        if x == '-' :
            return (x, psy, phy)
        elif 59640<=idx<=72417 and x=='2':
            return ('-',psy, phy)
        elif idx<=107313 and x=='1':
            return ('2',psy, phy)
        elif idx>=107313 and x!='-' :
            return (str(int(x)+1),psy, phy)
            
        return (str(x),psy,phy)
    
    ecg_df[['stage', 'psychology_RPE', 'physiology_RPE']] = ecg_df.apply(modify_value, axis=1, result_type='expand')
    
    to_csv_path = deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv'
    ecg_df.to_csv(to_csv_path, index=False)
    # print(stage_divide(number,ecg_df))
    # print(stage_divide_info(number,ecg_df))


def handing_1048():
    person = '1048'
    number = '1048-1-1'
    ecg_df=pd.read_csv(deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv')
    # ecg_df, rrdata_df, ppg_df, rri_df, singlework_df, singledetail_df = df_get(deal_path, person, test)

    def modify_value(x):
        if x == '-':
            return x
        elif int(x) == 6:
            return '-'
        elif int(x) > 6:
            return int(x) - 1
        return str(x)

    ecg_df['stage'] = ecg_df['stage'].apply(modify_value)

    to_csv_path = deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv'
    ecg_df.to_csv(to_csv_path, index=False)
    print('1048修正完成')


def handing_1049():
    person = '1049'
    number = '1049-1-1'
    ecg_df=pd.read_csv(deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv')

    def modify_value(row):
        x = row['stage']
        idx = row.name
        if x == '-':
            return x
        elif int(x) == 3 and idx <= 225149:
            return '-'
        elif int(x) > 0 and idx >= 225149:
            return int(x) + 2

    ecg_df['stage'] = ecg_df.apply(modify_value, axis=1)

    to_csv_path = deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv'
    ecg_df.to_csv(to_csv_path, index=False)
    print('1049修正完成')


def handing_1050():
    person = '1050'
    number = '1050-1-1'
    
    ecg_df=pd.read_csv(deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv')
    def modify_value(row):
        x = row['stage']
        psy=row['psychology_RPE']
        phy=row['physiology_RPE']
        idx = row.name
        
        if 588460<=idx<=588500 :
            return ('-','8', '8')
        
        
        return (str(x),psy,phy)
    
    ecg_df[['stage', 'psychology_RPE', 'physiology_RPE']] = ecg_df.apply(modify_value, axis=1, result_type='expand')
    
    to_csv_path = deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv'
    
    ecg_df.to_csv(to_csv_path, index=False)
    # print(stage_divide(number,ecg_df))
    # print(stage_divide_info(number,ecg_df))

def handing_1053():
    person = '1053'
    number = '1053-1-1'
    
    ecg_df=pd.read_csv(deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv')
    def modify_value(row):
        x = row['stage']
        psy=row['psychology_RPE']
        phy=row['physiology_RPE']
        idx = row.name
        
        if idx<=66506 and x!='-':
            return ('1',psy, phy)
        elif 66906<=idx<=166369 and x!='-':
            return ('2',psy, phy)
        elif 187173<=idx<=227494 :
            # print('xiugai',idx,x)
            return ('3',psy, phy)
        elif 227594<=idx<=227667:
            # print('xiugai',idx,x,psy,phy)
            return ('-','0', '2')
        elif 792502<=idx<=816507 and x!='-':
            return ('15',psy, phy)
        elif x=='17':
            return ('16',psy, phy)
        return (str(x),psy,phy)
    
    ecg_df[['stage', 'psychology_RPE', 'physiology_RPE']] = ecg_df.apply(modify_value, axis=1, result_type='expand')
    
    to_csv_path = deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv'
    ecg_df.to_csv(to_csv_path, index=False)
    # print(stage_divide(number,ecg_df))
    # print(stage_divide_info(number,ecg_df))



def handing_1054():
    person = '1054'
    number = '1054-1-1'
    
    ecg_df=pd.read_csv(deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv')
    def modify_value(row):
        x = row['stage']
        psy=row['psychology_RPE']
        phy=row['physiology_RPE']
        idx = row.name
        
        if 689342<=idx<=689445:
            return ('-','7', '8')
        
        return (str(x),psy,phy)
    
    ecg_df[['stage', 'psychology_RPE', 'physiology_RPE']] = ecg_df.apply(modify_value, axis=1, result_type='expand')
    
    to_csv_path = deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv'
    ecg_df.to_csv(to_csv_path, index=False)
    # print(stage_divide(number,ecg_df))
    # print(stage_divide_info(number,ecg_df))


def handing_1056():
    person = '1056'
    number = '1056-1-1'
    ecg_df=pd.read_csv(deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv')

    def modify_value(x):
        if x == '-':
            return x
        elif int(x) == 3:
            return '-'
        elif int(x) > 3:
            return int(x) - 1
        return str(x)

    ecg_df['stage'] = ecg_df['stage'].apply(modify_value)

    to_csv_path = deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv'
    ecg_df.to_csv(to_csv_path, index=False)
    print('1056修正完成')
def handing_1059():
    person = '1059'
    number = '1059-1-1'
    ecg_df=pd.read_csv(deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv')

    # def modify_value(x):
    #     if x == '-':
    #         return x
    #     elif int(x) == 3:
    #         return '-'
    #     elif int(x) > 3:
    #         return int(x) - 1
    #     return str(x)

    # ecg_df['stage'] = ecg_df['stage'].apply(modify_value)

    # to_csv_path = deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv'
    # ecg_df.to_csv(to_csv_path, index=False)
    # print(stage_divide(number,ecg_df))
    # print(stage_divide_info(number,ecg_df))
    # print('1056修正完成')

def handing_1060():
    person = '1060'
    number = '1060-1-1'
    
    ecg_df=pd.read_csv(deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv')
    def modify_value(row):
        x = row['stage']
        psy=row['psychology_RPE']
        phy=row['physiology_RPE']
        idx = row.name
        
        if idx<=23648 and x=='2':
            return ('-',psy, phy)
        
        return (str(x),psy,phy)
    
    ecg_df[['stage', 'psychology_RPE', 'physiology_RPE']] = ecg_df.apply(modify_value, axis=1, result_type='expand')
    
    to_csv_path = deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv'
    
    ecg_df.to_csv(to_csv_path, index=False)
    # print(stage_divide(number,ecg_df))
    # print(stage_divide_info(number,ecg_df))




def handing_1063():
    person = '1063'
    number = '1063-1-1'
    
    ecg_df=pd.read_csv(deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv')
    def modify_value(row):
        x = row['stage']
        psy=row['psychology_RPE']
        phy=row['physiology_RPE']
        idx = row.name
        
        if 412023<=idx<=412096 :
            return ('-','3', '1')
        
        return (str(x),psy,phy)
    
    ecg_df[['stage', 'psychology_RPE', 'physiology_RPE']] = ecg_df.apply(modify_value, axis=1, result_type='expand')
    
    to_csv_path = deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv'
    
    ecg_df.to_csv(to_csv_path, index=False)
    # print(stage_divide(number,ecg_df))
    # print(stage_divide_info(number,ecg_df))



def handing_1066():
    person = '1066'
    number = '1066-1-1'
    
    ecg_df=pd.read_csv(deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv')
    def modify_value(row):
        x = row['stage']
        psy=row['psychology_RPE']
        phy=row['physiology_RPE']
        idx = row.name
        
        if 499186<=idx<=499259 :
            return ('-','3', '3')
        
        return (str(x),psy,phy)
    
    ecg_df[['stage', 'psychology_RPE', 'physiology_RPE']] = ecg_df.apply(modify_value, axis=1, result_type='expand')
    
    to_csv_path = deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv'
    
    ecg_df.to_csv(to_csv_path, index=False)
    print('1066修正完成')
    # print(stage_divide(number,ecg_df))
    # print(stage_divide_info(number,ecg_df))


def handing_1070():
    person = '1070'
    number = '1070-1-1'
    
    ecg_df=pd.read_csv(deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv')
    def modify_value(row):
        x = row['stage']
        psy=row['psychology_RPE']
        phy=row['physiology_RPE']
        idx = row.name
        
        if 274564<=idx<=274637 :
            return ('-','1', '1')
        
        return (str(x),psy,phy)
    
    ecg_df[['stage', 'psychology_RPE', 'physiology_RPE']] = ecg_df.apply(modify_value, axis=1, result_type='expand')
    
    to_csv_path = deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv'
    
    ecg_df.to_csv(to_csv_path, index=False)
    # print(stage_divide(number,ecg_df))
    # print(stage_divide_info(number,ecg_df))



def handing_1072():
    person = '1072'
    number = '1072-1-1'
    
    ecg_df=pd.read_csv(deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv')
    def modify_value(row):
        x = row['stage']
        psy=row['psychology_RPE']
        phy=row['physiology_RPE']
        idx = row.name
        
        if 106296<=idx<= 192487:
            return ('2','-', '-')
        
        return (str(x),psy,phy)
    
    ecg_df[['stage', 'psychology_RPE', 'physiology_RPE']] = ecg_df.apply(modify_value, axis=1, result_type='expand')
    
    to_csv_path = deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv'
    
    ecg_df.to_csv(to_csv_path, index=False)
    # print(stage_divide(number,ecg_df))
    # print(stage_divide_info(number,ecg_df))




def handing_1076():
    person = '1076'
    number = '1076-1-1'
    
    ecg_df=pd.read_csv(deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv')
    def modify_value(row):
        x = row['stage']
        psy=row['psychology_RPE']
        phy=row['physiology_RPE']
        idx = row.name
        
        if x=='3' :
            return ('2',psy, phy)
        elif x>='3':
            return (str(int(x)-1),psy,phy)
        
        return (str(x),psy,phy)
    
    ecg_df[['stage', 'psychology_RPE', 'physiology_RPE']] = ecg_df.apply(modify_value, axis=1, result_type='expand')
    
    to_csv_path = deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv'
    
    ecg_df.to_csv(to_csv_path, index=False)
    # print(stage_divide(number,ecg_df))
    # print(stage_divide_info(number,ecg_df))
def handing_1083():
    person = '1083'
    number = '1083-1-1'
    
    ecg_df=pd.read_csv(deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv')
    def modify_value(row):
        x = row['stage']
        psy=row['psychology_RPE']
        phy=row['physiology_RPE']
        idx = row.name
        
        if x=='3' :
            return ('-',psy, phy)
        elif x=='2' and psy=='1':
            return ('2','-', '-')
        elif x>'3':
            return (str(int(x)-1),psy,phy)
        
        return (str(x),psy,phy)
    
    ecg_df[['stage', 'psychology_RPE', 'physiology_RPE']] = ecg_df.apply(modify_value, axis=1, result_type='expand')
    
    to_csv_path = deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv'
    
    ecg_df.to_csv(to_csv_path, index=False)
    # print(stage_divide(number,ecg_df))
    # print(stage_divide_info(number,ecg_df))

def handing_1089():
    person = '1089'
    number = '1089-1-1'
    
    ecg_df=pd.read_csv(deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv')
    def modify_value(row):
        x = row['stage']
        psy=row['psychology_RPE']
        phy=row['physiology_RPE']
        idx = row.name
        
        if 557736<=idx<=5577809 :
            return ('-','4', '4')
        
        
        return (str(x),psy,phy)
    
    ecg_df[['stage', 'psychology_RPE', 'physiology_RPE']] = ecg_df.apply(modify_value, axis=1, result_type='expand')
    
    to_csv_path = deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv'
    
    ecg_df.to_csv(to_csv_path, index=False)
    # print(stage_divide(number,ecg_df))
    # print(stage_divide_info(number,ecg_df))

def handing_1091():
    person = '1091'
    number = '1091-1-1'
    
    ecg_df=pd.read_csv(deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv')
    def modify_value(row):
        x = row['stage']
        psy=row['psychology_RPE']
        phy=row['physiology_RPE']
        idx = row.name
        
        if 344570<=idx<=344650 :
            return ('-','2', '2')
        elif  x=='9' and psy=='4':
            return ('9','-','-')
        
        
        return (str(x),psy,phy)
    
    ecg_df[['stage', 'psychology_RPE', 'physiology_RPE']] = ecg_df.apply(modify_value, axis=1, result_type='expand')
    
    to_csv_path = deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv'
    
    ecg_df.to_csv(to_csv_path, index=False)
    # print(stage_divide(number,ecg_df))
    # print(stage_divide_info(number,ecg_df))


def handing_1103():
    person = '1103'
    number = '1103-1-1'
    
    ecg_df=pd.read_csv(deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv')
    def modify_value(row):
        x = row['stage']
        psy=row['psychology_RPE']
        phy=row['physiology_RPE']
        idx = row.name
        
        if 516255<=idx<=516331 :
            return ('-','-', '-')
        elif  303755<=idx<=303828:
            return ('-','4', '5')
        elif x=='11' and psy=='2':
            return ('11','-','-')
        elif idx>=543634 and psy=='2':
            return (x,'-','-')

        return (str(x),psy,phy)
    
    ecg_df[['stage', 'psychology_RPE', 'physiology_RPE']] = ecg_df.apply(modify_value, axis=1, result_type='expand')
    
    to_csv_path = deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv'
    
    ecg_df.to_csv(to_csv_path, index=False)
    # print(stage_divide(number,ecg_df))
    # print(stage_divide_info(number,ecg_df))



def handing_1109():
    person = '1109'
    number = '1109-1-1'
    
    ecg_df=pd.read_csv(deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv')
    def modify_value(row):
        x = row['stage']
        psy=row['psychology_RPE']
        phy=row['physiology_RPE']
        idx = row.name
        
        if 440120<=idx<=440490 :
            return ('-','4', '5')
        

        return (str(x),psy,phy)
    
    ecg_df[['stage', 'psychology_RPE', 'physiology_RPE']] = ecg_df.apply(modify_value, axis=1, result_type='expand')
    
    to_csv_path = deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv'
    
    ecg_df.to_csv(to_csv_path, index=False)
    # print(stage_divide(number,ecg_df))
    # print(stage_divide_info(number,ecg_df))


def handing_1111():
    person = '1111'
    number = '1111-1-1'
    
    ecg_df=pd.read_csv(deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv')
    def modify_value(row):
        x = row['stage']
        psy=row['psychology_RPE']
        phy=row['physiology_RPE']
        idx = row.name
        
        if x=='6':
            return ('-','-','-')
        elif x>='7':
            return (str(int(x)-1),psy,phy)
        elif 360920<=idx<=360990:
            return ('-','4','5')

        return (str(x),psy,phy)
    
    ecg_df[['stage', 'psychology_RPE', 'physiology_RPE']] = ecg_df.apply(modify_value, axis=1, result_type='expand')
    
    to_csv_path = deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv'
    
    ecg_df.to_csv(to_csv_path, index=False)
    print('1111修正完成')
    # print(stage_divide(number,ecg_df))
    # print(stage_divide_info(number,ecg_df))


def handing_1112():
    person = '1112'
    number = '1112-1-1'
    
    ecg_df=pd.read_csv(deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv')
    def modify_value(row):
        x = row['stage']
        psy=row['psychology_RPE']
        phy=row['physiology_RPE']
        idx = row.name
        
        if (x=='2'or'-') and idx<=66084:
            return ('1',psy,phy)
        elif x>='2':
            return (str(int(x)-1),psy,phy)
         

        return (str(x),psy,phy)
    
    ecg_df[['stage', 'psychology_RPE', 'physiology_RPE']] = ecg_df.apply(modify_value, axis=1, result_type='expand')
    
    to_csv_path = deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv'
    
    ecg_df.to_csv(to_csv_path, index=False)
    # print(stage_divide(number,ecg_df))
    # print(stage_divide_info(number,ecg_df))


def handing_1113():
    person = '1113'
    number = '1113-1-1'
    
    ecg_df=pd.read_csv(deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv')
    def modify_value(row):
        x = row['stage']
        psy=row['psychology_RPE']
        phy=row['physiology_RPE']
        idx = row.name
        
        if (x=='1') and idx<=68910:
            return ('-',psy,phy)
        
         

        return (str(x),psy,phy)
    
    ecg_df[['stage', 'psychology_RPE', 'physiology_RPE']] = ecg_df.apply(modify_value, axis=1, result_type='expand')
    
    to_csv_path = deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv'
    
    ecg_df.to_csv(to_csv_path, index=False)
    print(stage_divide(number,ecg_df))
    print(stage_divide_info(number,ecg_df))



def handing_1115():
    person = '1115'
    number = '1115-1-1'
    
    ecg_df=pd.read_csv(deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv')
    # def modify_value(row):
    #     x = row['stage']
    #     psy=row['psychology_RPE']
    #     phy=row['physiology_RPE']
    #     idx = row.name
        
    #     if (x=='1') and idx<=68910:
    #         return ('-',psy,phy)
        
         

    #     return (str(x),psy,phy)
    
    # ecg_df[['stage', 'psychology_RPE', 'physiology_RPE']] = ecg_df.apply(modify_value, axis=1, result_type='expand')
    
    # to_csv_path = deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv'
    
    # ecg_df.to_csv(to_csv_path, index=False)
    print(stage_divide(number,ecg_df))
    print(stage_divide_info(number,ecg_df))


def handing_1116():
    person = '1116'
    number = '1116-1-1'
    
    ecg_df=pd.read_csv(deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv')
    # def modify_value(row):
    #     x = row['stage']
    #     psy=row['psychology_RPE']
    #     phy=row['physiology_RPE']
    #     idx = row.name
        
    #     if (x=='1') and idx<=68910:
    #         return ('-',psy,phy)
        
         

    #     return (str(x),psy,phy)
    
    # ecg_df[['stage', 'psychology_RPE', 'physiology_RPE']] = ecg_df.apply(modify_value, axis=1, result_type='expand')
    
    # to_csv_path = deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv'
    
    # ecg_df.to_csv(to_csv_path, index=False)
    print(stage_divide(number,ecg_df))
    print(stage_divide_info(number,ecg_df))


def handing_1118():
    person = '1118'
    number = '1118-1-1'
    
    ecg_df=pd.read_csv(deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv')
    def modify_value(row):
        x = row['stage']
        psy=row['psychology_RPE']
        phy=row['physiology_RPE']
        idx = row.name
        
        if x=='3' :
            return ('-',psy,phy)
        elif x=='2'and psy=='4':
                return ('2','-','-')
        elif idx>=186880:
            if x=='7' and psy=='5':
                return ('6','-','-')
            
            elif x=='7'and 371490<=idx<=371504:
                return ('-','6','6')
            elif x=='8'and 371504<=idx<=379384:
                return ('-','-','-')
            elif x>='4':
                return (str(int(x)-1),psy,phy)
            

        return (str(x),psy,phy)
    
    ecg_df[['stage', 'psychology_RPE', 'physiology_RPE']] = ecg_df.apply(modify_value, axis=1, result_type='expand')
    
    to_csv_path = deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv'
    
    ecg_df.to_csv(to_csv_path, index=False)
    print(stage_divide(number,ecg_df))
    print(stage_divide_info(number,ecg_df))

def handing_1121():
    person = '1121'
    number = '1121-1-1'
    
    ecg_df=pd.read_csv(deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv')
    def modify_value(row):
        x = row['stage']
        psy=row['psychology_RPE']
        phy=row['physiology_RPE']
        idx = row.name
        
        if 210490<=idx<=210563:
            return ('-','2','2')
        elif x>='5':
            return (str(int(x)-1),psy,phy)
         
        
            

        return (str(x),psy,phy)
    
    ecg_df[['stage', 'psychology_RPE', 'physiology_RPE']] = ecg_df.apply(modify_value, axis=1, result_type='expand')
    
    to_csv_path = deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv'
    
    ecg_df.to_csv(to_csv_path, index=False)
    print(stage_divide(number,ecg_df))
    print(stage_divide_info(number,ecg_df))
def handing_1125():
    person = '1125'
    number = '1125-1-1'
    
    ecg_df=pd.read_csv(deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv')
    def modify_value(row):
        x = row['stage']
        psy=row['psychology_RPE']
        phy=row['physiology_RPE']
        idx = row.name
        
        if 210490<=idx<=210563:
            return ('-','2','2')
        elif x>='5':
            return (str(int(x)-1),psy,phy)
         
        
            

        return (str(x),psy,phy)
    
    ecg_df[['stage', 'psychology_RPE', 'physiology_RPE']] = ecg_df.apply(modify_value, axis=1, result_type='expand')
    
    to_csv_path = deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv'
    
    ecg_df.to_csv(to_csv_path, index=False)
    print(stage_divide(number,ecg_df))
    print(stage_divide_info(number,ecg_df))
def handing_1127():
    person = '1127'
    number = '1127-1-1'
    
    ecg_df=pd.read_csv(deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv')
    def modify_value(row):
        x = row['stage']
        psy=row['psychology_RPE']
        phy=row['physiology_RPE']
        idx = row.name
        
        if 385661<=idx<=385741:
            return ('-','7','7')
        
         
        
            

        return (str(x),psy,phy)
    
    ecg_df[['stage', 'psychology_RPE', 'physiology_RPE']] = ecg_df.apply(modify_value, axis=1, result_type='expand')
    
    to_csv_path = deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv'
    
    ecg_df.to_csv(to_csv_path, index=False)
    print(stage_divide(number,ecg_df))
    print(stage_divide_info(number,ecg_df))



def handing_1129():
    person = '1129'
    number = '1129-1-1'
    
    ecg_df=pd.read_csv(deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv')
    def modify_value(row):
        x = row['stage']
        psy=row['psychology_RPE']
        phy=row['physiology_RPE']
        idx = row.name
        
        if 350500<=idx<=350570:
            return ('-','5','5')
        
         
        
            

        return (str(x),psy,phy)
    
    ecg_df[['stage', 'psychology_RPE', 'physiology_RPE']] = ecg_df.apply(modify_value, axis=1, result_type='expand')
    
    to_csv_path = deal_path + '\\' + person + '\\' + number + '-ecg' + '.csv'
    
    ecg_df.to_csv(to_csv_path, index=False)
    print(stage_divide(number,ecg_df))
    print(stage_divide_info(number,ecg_df))



def handing_1133():
    return
def handung_1035():
    return

# def handing_1010():
#     person = '1010'
#     test = '1010-1-1'
#     ecg_df, rrdata_df, ppg_df, rri_df, singlework_df, singledetail_df = df_get(deal_path, person, test)

#     def modify_value(row):
#         x = row['stage']
#         idx = row.name
#         if x != '-'  and 481594 <= idx:
#             return int(x)+9

#         return str(x)

#     ecg_df['stage'] = ecg_df.apply(modify_value, axis=1)

#     to_csv_path = deal_path + '\\' + person + '\\' + test + '-ecg' + '.csv'
#     ecg_df.to_csv(to_csv_path, index=False)
#     print('1010修正完成')
# def handing_1008():
#     person = '1008'
#     test = '1008-1-1'
#     ecg_df, rrdata_df, ppg_df, rri_df, singlework_df, singledetail_df = df_get(deal_path, person, test)

#     def modify_value(row):
#         x = row['stage']
#         idx = row.name
#         if x != '-'  and 513272 <= idx:
#             return int(x)+10

#         return str(x)

#     ecg_df['stage'] = ecg_df.apply(modify_value, axis=1)

#     to_csv_path = deal_path + '\\' + person + '\\' + test + '-ecg' + '.csv'
#     ecg_df.to_csv(to_csv_path, index=False)
#     print('1008修正完成')

